<%-- 
    Document   : check
    Created on : Jul 27, 2012, 12:52:03 PM
    Author     : Andrew
--%>

<%@ page language="java" import="captchas.CaptchasDotNet" %>
<%@page import="java.util.*" %>
 
<html>
   <head>
     <title>Check Registration</title>
   </head>
   <h1>Check Registration</h1>
   
   
   <jsp:useBean id="user" scope="session" class="business.User"/>
    <table cellspacing="5" cellpadding="5" border="1">
    <tr>
        <td align="right">First name:</td>
        <td><jsp:getProperty name="user" property="firstName"/></td>
    </tr>
    <tr>
        <td align="right">Last name:</td>
        <td><jsp:getProperty name="user" property="lastName"/></td>
    </tr>
    <tr>
        <td align="right">Email address:</td>
        <td><jsp:getProperty name="user" property="emailAddress"/></td>
    </tr>
    
     <tr>
        <td align="right">PassWord:</td>
        <td><jsp:getProperty name="user" property="passWord"/></td>
    </tr>
    
    
</table>
   
   
 <%
 // Construct the captchas object
 // Use same settings as in query.jsp
 CaptchasDotNet captchas = new captchas.CaptchasDotNet(
   request.getSession(true),     // Ensure session
   "demo",                       // client
   "secret"                      // secret
   );
 // Read the form values

 String CAPTCHA = request.getParameter("CAPTCHA");
 
// Check captcha
 String body;
 switch (captchas.check(CAPTCHA)) {
   case 's':
     body = "Session seems to be timed out or broken. ";
     body += "Please try again or report error to administrator.";
     break;
   case 'm':
     body = "Every CAPTCHA can only be used once. ";
     body += "The current CAPTCHA has already been used. ";
     body += "Please use back button and reload";
     break;
   case 'w':
     body = "You entered the incorrect CATCHA code`. ";
     body += "Please use back button and try again. ";
     break;
   default:
     body = "Successful login. The parameter key and values are ";
    Enumeration enumeration = request.getParameterNames();
    while (enumeration.hasMoreElements()) {
        String key =(String) enumeration.nextElement();
        String vals[] = request.getParameterValues(key);
        for (int i=0, max=vals.length; i<max; i++) {
            body += "<br>" +" key:"+key+" value:"+vals[i] ;
        }
    }
    break;

 }
 %>
 <%=body%>
 </html>